//
//  IDViewController.m
//  jiejie
//
//  Created by youyoumacmini3 on 17/3/24.
//  Copyright © 2017年 youyoumacmini3. All rights reserved.
//

#import "IDViewController.h"
#import "JGPopView.h"
#import "UIViewController+HUD.h"

#import "gameOneViewController.h"
@interface IDViewController ()<selectIndexPathDelegate,UITextFieldDelegate>
{
    NSString *str;
}
//保存所有日志类型
@property (nonatomic, strong) NSArray *logTypeArrM;
@property (weak, nonatomic) IBOutlet UIButton *creatBtn;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextField *trueName;
@property (weak, nonatomic) IBOutlet UITextField *loveName;
@property (weak, nonatomic) IBOutlet UITextField *code;
@property (weak, nonatomic) IBOutlet UITextField *gameName;

@end

@implementation IDViewController

- (NSArray *)logTypeArrM {
    
    if (!_logTypeArrM) {
        _logTypeArrM = @[@"宇宙超级无敌美丽可爱萌萌哒小公主仙女 【好感度20】（5元）",@"普通邻家小妹【好感度5】（1元）"];
    }
    return _logTypeArrM;
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self hide];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    str = @"0";
    self.label.numberOfLines = 0;
    [_creatBtn setShowsTouchWhenHighlighted:YES];
    
    
    self.code.delegate = self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)sure:(id)sender {
    
    self.view.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.8];
    [self showStatus:@"正在初始化角色中..." imageName:@"gif" type:@"gif" tapViewWithBlock:^{
        NSLog(@"点击屏幕了");
    }];
    
    // 隐藏，三秒后消失
     __weak typeof(self) __weakSelf = self;
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
     
         
         self.view.backgroundColor = [UIColor whiteColor];
         [__weakSelf hide];
         [self performSegueWithIdentifier:@"gameOne" sender:self.gameName.text];
     });
     
     
    
    
    
    
    
}
- (IBAction)cancel:(id)sender {
}
- (IBAction)creat:(UIButton*)btn {
    if ([str isEqualToString:@"0"]) {
        CGPoint point = CGPointMake(btn.center.x-50,btn.frame.origin.y + 45);
        JGPopView *view2 = [[JGPopView alloc] initWithOrigin:point Width:300 Height:80 * 2 Type:JGTypeOfUpCenter Color:[UIColor cyanColor]];
        //    view2.dataArray = @[@"发起群聊",@"添加朋友", @"扫一扫", @"收付款"];
        //    view2.images = @[@"发起群聊",@"添加朋友", @"扫一扫", @"付款"];
        view2.dataArray = self.logTypeArrM;
        view2.fontSize = 13;
        view2.row_height = 40;
        view2.titleTextColor = [UIColor blackColor];
        view2.delegate = self;
        [view2 popView];
    }else{
        NSURL * url = [NSURL URLWithString:@"weixin://"];
        [[UIApplication sharedApplication] openURL:url];
    }
  
}

- (void)selectIndexPathRow:(NSInteger)index{
    
    //    JGLog(@"=====%@",[self.allNameArrM objectAtIndex:index]);
    str = @"1";
    
    self.label.text = @"已选择，请前往支付，支付前请自行说明购买产品（可换取对应的设置码填写即可生成角色），由于本人很懒没写修改，如想重选请返回上个界面";
    
    [self.creatBtn setTitle:@"已选择，请前往支付" forState:UIControlStateNormal];
    
}


- (void)textFieldDidBeginEditing:(UITextField *)textField{
    NSLog(@"--00000000000000000000000000000000");
    
    [UIView animateWithDuration:1.0 animations:^{
       
        self.view.frame = CGRectMake(0, -200, self.view.frame.size.width, self.view.frame.size.height);
    }];
    
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    [UIView animateWithDuration:1.0 animations:^{
        
        self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    }];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
 */
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([segue.identifier isEqualToString:@"gameOne"]) {
        NSString *strr = (NSString*)sender;
        gameOneViewController*gameOneVC = segue.destinationViewController;
        gameOneVC.name = strr;
    }
    
    
    
}


@end
